<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
      // // 1、js一共有多少种数据类型?
      Boolean,String,Number,对象,数组,函数
      // 2、js检测数据类型有哪些方法?
      typeof 数值
      需要检测数据 instanceof 构造函数
      Object.prototype.toString.call(需要检测的数据);
      // 3、undefined和null的区别?	用typeof检测它们分别返回什么值?
      undefined是未定义,没有赋值
      null是空值
      分别返回undefind和object
      // 4、写出下列对应结果
      let str_4 = '0';
      Boolean(str_4);//ture

      let str1_4 = '';//空
      Boolean(str1_4);//false

      let str2_4 = ' ';//空格
      Boolean(str2_4);//true

      let unde_4 = undefined;//未定义
      Boolean(unde_4);//false

      let nu_4 = null;
      Boolean(nu_4);//false

      let num_4 = 0;
      Boolean(num_4);//false

      let num1_4 = -10;
      Boolean(num1_4);//true

      // 5、写出下列对应结果	注意：需要分别使用Number、String、toString去转换数据类型
      let str_5 = '0';
      Number(str_5);//0
      String(str_5);//'0'
      toString(str_5)//[object String]
      let num_5 = -10;
      Number(num_5);//-10
      String(num_5);//'-10'
      toString(num_5);//[object Number]
      let flag_5 = true;
      Number(flag_5);
      String(flag_5);'ture'
      toString(flag_5);//[object Boolean]
      let ud_5 = undefined;
      Number(ud_5);//NaN
      String(ud_5);//'undefined'
      toString(ud_5)//[object Undefined]
      let nu_5 = null;
      Number(nu_5);//0
      String(nu_5);//'null'
      toString(nu_5);//[object Undefined]
      // 6、检测下面的变量各自的数据类型
      let str_6 = '';//String
      let num_6 = '-10';//String
      let num1_6 = 0;//Number
      let nu_6 = undefined;//Undefined
      let nu1_6 = 'undefined';//String
      let nu2_6 = 'null';//String
      let nu3_6 = null;//Undefined
      let obj_6 = '{}';//String
      let obj1_6 = {};//Object
      let sy_6 = Symbol('n');//Symbol
    </script>
  </body>
</html>
